/*
 * Project Name: cms_manager
 * File Name: ClassesService.java
 * Copyright: ZKTeco Corporation 2015
 * Description: TODO 请在此处添加对本文件的描述
 * Creator: Administrator
 * Create Date: 2015年3月16日 下午2:00:45
 */
package com.shishuo.cms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shishuo.cms.dao.ClassesDao;
import com.shishuo.cms.entity.Admin;
import com.shishuo.cms.entity.ClassesEntity;
import com.shishuo.cms.entity.vo.PageVo;

/**
 * 栏目类型
 * 
 * @since 2015年3月16日 下午2:00:45
 */
@Service
public class ClassesService extends BaseService<ClassesEntity, Long>
{
	private ClassesDao classesDao;

	@Autowired
	public void setClassesDao(ClassesDao classesDao)
	{
		super.setBaseDao(classesDao);
		this.classesDao = classesDao;
	}

	public List<ClassesEntity> getClassesByType(ClassesEntity classesEntity)
	{
		return classesDao.getClassesByType(classesEntity);
	}

	public List<ClassesEntity> getChildClasses(long fatherId,int isShowOnIndex,int isHeader,int isShowRollOnIndexPage)
	{
		return classesDao.getChildClasses(fatherId,isShowOnIndex,isHeader,isShowRollOnIndexPage);
	}

	public boolean isExistByAliasName(String aliasName)
	{
		return (classesDao.getByAliasName(aliasName) == null) ? false : true;
	}

	/**
	 *
	 * @param pageNum
	 * @return
	 * @throws Exception
	 */
	public PageVo<ClassesEntity> getAllListPage(int pageNum) throws Exception
	{
		PageVo<ClassesEntity> pageVo = new PageVo<ClassesEntity>(pageNum);
		List<ClassesEntity> list = this
				.getAllList(pageVo.getOffset(), pageVo.getRows());
		pageVo.setList(list);
		pageVo.setCount(this.getAllListCount());
		return pageVo;
	}
	/**
	 * 模糊查询关键字
	 * @param pageNum
	 * @return
	 * @throws Exception
	 */
	public PageVo<ClassesEntity> getSearchListByAliasName(int pageNum,String keyWords) throws Exception
	{
		PageVo<ClassesEntity> pageVo = new PageVo<ClassesEntity>(pageNum);
		pageVo.setRows(30);
		List<ClassesEntity> list = classesDao
				.getSearchListByAliasName(pageVo.getOffset(), pageVo.getRows(),keyWords);
		pageVo.setList(list);
		pageVo.setCount(classesDao.getSearchListByAliasNameCount(keyWords));
		return pageVo;
	}
	
	public ClassesEntity getByAliasName(String aliasName) {
		return classesDao.getByAliasName(aliasName);
	}
}
